package com.itheima.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/*
时间日期格式化类
 */
public class Demo03 {


    public static void main(String[] args) throws ParseException {
        Date date = new Date();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy,MM,dd, HH:mm:ss");
        //格式化  Date-> String
        String dateStr = sdf.format(date);
        System.out.println(dateStr);

        String  s="1991-01-01 5:10:10";
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = sdf2.parse(s);
        System.out.println(parse);


    }
}
